﻿using RazorHelper.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RazorHelper.Controllers
{
    public class HelperController : Controller
    {
        //
        // GET: /Helper/
        public ActionResult SelectionList()
        {
            var list = new List<Country>()
            {
                new Country{Id="VN", Name="Việt Nam"},
                new Country{Id="US", Name="United States"},
                new Country{Id="UK", Name="United Kindom"},
                new Country{Id="AU", Name="Astralia"},
                new Country{Id="SG", Name="Singapore"}
            };

            // Chuyển cho DropDownList và ListBox
            ViewBag.Countries = new SelectList(list, "Id", "Name");

            return View();
        }

        public ActionResult Format()
        {
            ViewBag.Number1 = 123456.78;
            ViewBag.Number2 = 0.24;

            ViewBag.Date = DateTime.Now;

            ViewBag.Html = "<i>I am Nghiem</i>";

            return View();
        }

        public ActionResult Register()
        {
            var model = new Student();
            model.Id = "nnghiem";
            model.FullName = "Nguyễn Nghiệm";
            return View(model);
        }

        public ActionResult Register2()
        {
            var model = new Student2();
            model.Id = "nnghiem";
            model.FullName = "Nguyễn Nghiệm";
            return View(model);
        }

        public ActionResult GenerateUIForModel()
        {
            var model = new Student2();
            model.Id = "nnghiem";
            model.FullName = "Nguyễn Nghiệm";

            // Truyền cho Html.Editor("MyStudent")
            ViewBag.MyStudent = model;

            return View(model);
        }
	}
}